package org.example.controller;

import org.example.util.SessionUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(produces = "application/json;charset=utf-8")
public class UserController {

    @Resource
    private SessionUtil sessionUtil;

    @RequestMapping("/getsession")
    public String getSession(String token,Integer id){
            sessionUtil.setSession(token,id);
            return "ok";
    }

    @RequestMapping("/getname")
    public String getName(Integer id){
        String token = sessionUtil.getToken(id);
        System.out.println("token="+token);
        return token;
    }
}
